let startBtn = document.querySelector(".startBtn");
let prizeCell = document.querySelectorAll(".drawBox div:not(.startBtn)")
let wwe = document.querySelector(".wwe")
let we = document.querySelector(".we")

let index = 0;
let targetIndex = 84;
let timer;
let second = 200;
let isRun = true;

// 开始抽奖升级版

startBtn.addEventListener("click", function () {
    if (isRun) {
        isRun = false;
        run();
    }
})

function run() {

    setTimeout(function () {

        if (index) {
            prizeCell[(index - 1) % 8].classList.remove("active");

        }
        prizeCell[index % 8].classList.add("active");

        if (index < targetIndex) {
            run();
        } else {
            isRun = true;
        }
        we.innerHTML = prizeCell[index % 8].lastElementChild.innerHTML;
        wwe.innerHTML = prizeCell[index % 8].firstElementChild.outerHTML;
        index++;

        if (second > 30 && index < 20) {
            // 加速
            second -= 20;
        } else if (index > 60) {
            // 减速
            second += 20;
        }

    }, second)
}
